package com.wn.icloud.common.utils;

import java.io.Serializable;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;

/**
 * 树节点
 *
 * @author liguangcai
 * @date 2018/11/01 15:16
 */
public class TreeNode<T extends TreeNode> implements Serializable {

    protected String id;
    protected String parentId; // 直接父ID
    protected Instant endTime;
    protected String ancestorId;// 祖先ID

    List<T> children = new ArrayList<>();

    public void add(T node) {
        children.add(node);
    }

    public String getId() {
        return id;
    }

    public Instant getEndTime() {
        return endTime;
    }

    public void setEndTime(Instant endTime) {
        this.endTime = endTime;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public List<T> getChildren() {
        return children;
    }

    public void setChildren(List<T> children) {
        this.children = children;
    }

    public String getAncestorId() {
        return ancestorId;
    }

    public void setAncestorId(String ancestorId) {
        this.ancestorId = ancestorId;
    }
}
